package com.config;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.impl.AMQImpl;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 配置消息队列的：
 *   交换机
 *   队列
 *   绑定
 */
@Configuration
public class MQConfig {

    /**
     * 定义了交换机
     * @return
     */
    @Bean
    public FanoutExchange fanoutExchange()
    {
        return new FanoutExchange("fanoutExchange_2020_2");
    }

    /**
     * 队列
     * @return
     */
    @Bean("queue_2020_2_1")
    public Queue queue1()
    {
        return new Queue("queue_2020_2_1");
    }

    /**
     * 队列
     * @return
     */
    @Bean("queue_2020_2_2")
    public Queue queue2()
    {
        return new Queue("queue_2020_2_2");
    }


    @Bean("fanoutExchange_2020_2________________queue_2020_2_1")
    public Binding binding1()
    {
      return BindingBuilder.bind(queue1()).to(fanoutExchange());
    }

    @Bean("fanoutExchange_2020_2______________queue_2020_2_2")
    public Binding binding2()
    {
        return BindingBuilder.bind(queue2()).to(fanoutExchange());
    }





}












